<h3>Structure de contenu</h3>
<div>
	<form method="post">
		<table id="struc-row1">
			<tbody>
				<tr>
					<td>label</td>
					<td><input <?php echo 'value="'.$this->assign['dataStruct'][0]['contentobject_structure_label'].'"'; ?> name="contentobject_structure[contentobject_structure_label]" type="text" /></td>
				</tr>
				<tr>
					<td>caption</td>
					<td><input <?php echo 'value="'.$this->assign['dataStruct'][0]['contentobject_structure_caption'].'"'; ?> name="contentobject_structure[contentobject_structure_caption]" type="text" /></td>
				</tr>
			</tbody>
		</table>
	
		<table id="struc-row2">
			<thead>
				<th>position</th>
				<th>label</th>
				<th>caption</th>
				<th>type</th>
				<th>action</th>
			</thead>
			
			<tbody>
				<?php 
				foreach($this->assign['dataStruct'][0]['elems'] as $key => $val){
					echo'<tr>';
					echo'<td><input value="'.$val['contentobject_structure_elem_position'].'" name="contentobject_structure[elems]['.$key.'][contentobject_structure_position]" type="text" /></td>';
					echo'<td><input value="'.$val['contentobject_structure_elem_label'].'" name="contentobject_structure[elems]['.$key.'][contentobject_structure_label]" type="text" /></td>';
					echo'<td><input value="'.$val['contentobject_structure_elem_caption'].'" name="contentobject_structure[elems]['.$key.'][contentobject_structure_caption]" type="text" /></td>';
					echo'<td>';
						echo'<select name="contentobject_structure[elems]['.$key.'][contentobject_structure_type]">';
							if($val['input_fields_id']==1)$selected='selected="selected"';else $selected='';
							echo'<option '.$selected.' value="1" label="Texte Monoligne">Texte Monoligne</option>';
							if($val['input_fields_id']==2)$selected='selected="selected"';else $selected='';
							echo'<option '.$selected.' value="2" label="Texte Multiligne">Texte Multiligne</option>';
							if($val['input_fields_id']==6)$selected='selected="selected"';else $selected='';
							echo'<option '.$selected.' value="6" label="Date">Date</option>';
							if($val['input_fields_id']==3)$selected='selected="selected"';else $selected='';
							echo'<option '.$selected.' value="3" label="Media">Media</option>';
							if($val['input_fields_id']==7)$selected='selected="selected"';else $selected='';
							echo'<option '.$selected.' value="7" label="checkbox">checkbox</option>';
							if($val['input_fields_id']==8)$selected='selected="selected"';else $selected='';
							echo'<option '.$selected.' value="8" label="Select">Select</option>';
						echo'</select>';
					echo'</td>';
					echo'<td></td>';
				echo'</tr>';
				}
				?>
			</tbody>
		</table>
		
		<div><a class="btn-ajouter" href="#">+ ajouter</a></div>
		<div><input value="modifier" type="submit" /></div>
		<?php 
			echo '<input name="contentobject_structure[contentobject_id]" type="hidden" value="'.$this->args['path'][4].'" />';
		?>
	</form>
</div>


<script>
$('.btn-ajouter').live("click", function(){
	var uniqueID = new Date();
	var id_number =  uniqueID.getTime();

	var html='<tr>'+
		'<td><input name="contentobject_structure[elems]['+id_number+'][contentobject_structure_position]" type="text" /></td>'+
		'<td><input name="contentobject_structure[elems]['+id_number+'][contentobject_structure_label]" type="text" /></td>'+
		'<td><input name="contentobject_structure[elems]['+id_number+'][contentobject_structure_caption]" type="text" /></td>'+
		'<td>'+
			'<select name="contentobject_structure[elems]['+id_number+'][contentobject_structure_type]">'+
				'<option value="1" label="Texte Monoligne">Texte Monoligne</option>'+
				'<option value="2" label="Texte Multiligne">Texte Multiligne</option>'+
				'<option value="6" label="Date">Date</option>'+
				'<option value="3" label="Media">Media</option>'+
				'<option value="7" label="checkbox">checkbox</option>'+
				'<option value="8" label="Select">Select</option>'+
			'</select>'+
		'</td>'+
		'<td><input class="btn-supprimer" value="supprimer" name="btn-supprimer" type="button" /></td>'+
	'</tr>';

	$('table#struc-row2 tbody').append(html);
	
});

$('.btn-supprimer').live("click", function(){
	$(this).parent().parent().remove();
});

</script>